package com.woniuxy.qiantai.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SendEmailMQConfig {

    //声明以下内容:  交换机   队列   以及交换和队列的绑定关系

    //交换机
    @Bean
    public DirectExchange sendEmailExchange(){
        return new DirectExchange("sendEmailExchange");
    }

    //队列
    @Bean
    public Queue sendEmailQueue(){
        return new Queue("sendEmailQueue");
    }

    //交换机要和队列绑定到一起
    @Bean
    public Binding sendEmailBinding(){
        return BindingBuilder.bind(sendEmailQueue())
                .to(sendEmailExchange())
                .with("sendEmail");
    }




}
